import pywt
import matplotlib.pyplot as plt

class SignalFactory:
    def __init__(self):
        self.signal_names = [
            'Blocks', 'Bumps', 'HeaviSine', 'Doppler', 
            'Ramp', 'HiSine', 'LoSine', 'LinChirp', 
            'TwoChirp', 'QuadChirp', 'MishMash', 'WernerSorrows',
            'HypChirps', 'LinChirps', 'Chirps', 'Gabor', 
            'sineoneoverx', 'Piece-Regular', 'Piece-Polynomial', 'Riemann'
        ]
        self.default_length = 128
        self.fixed_length_signals = {'Gabor': 512, 'sineoneoverx': 1024}

    def create(self, name):
        if name in self.fixed_length_signals:
            return pywt.data.demo_signal(name, None)
        else:
            return pywt.data.demo_signal(name, self.default_length)

factory = SignalFactory()

plt.figure(figsize=(20, 16))
for idx, name in enumerate(factory.signal_names):
    signal = factory.create(name)
    plt.subplot(5, 4, idx + 1)
    plt.plot(signal)
    plt.title(name, fontsize=10, y=0.8)
    plt.tight_layout()
plt.rcParams['font.sans-serif'] = ['SimHei']  # 设置中文黑体
plt.rcParams['axes.unicode_minus'] = False    # 正确显示负号
plt.suptitle('Wavelab 测试信号全集', fontsize=10, y=1.00)
plt.show()